/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.model.events;

/**
 * <p>This is a subclass of XREEvent that represents mouse events. It defines some properties specific to these events.
 * Note that values of all custom properties are actually stored in the XREEvent#params map.</p>
 *
 * <p><strong>Thread safety:</strong> This class is mutable and not thread safe.</p>
 *
 * @author saarixx, jmn
 * @version 1.0
 */
@SuppressWarnings("boxing")
public class XREMouseEvent extends XREViewEvent {

    /**
     * <p>Represents the name of the "on mouse in" event. This is a string constant used by the user when setting the
     * name of the event.</p>
     */
    public static final String ON_MOUSE_IN_EVENT_NAME = "onMouseIn";

    /**
     * <p>Represents the name of the "on mouse out" event. This is a string constant used by the user when setting the
     * name of the event.</p>
     */
    public static final String ON_MOUSE_OUT_EVENT_NAME = "onMouseOut";

    /**
     * <p>Represents the name of the "on mouse up" event. This is a string constant used by the user when setting the
     * name of the event.</p>
     */
    public static final String ON_MOUSE_UP_EVENT_NAME = "onMouseUp";

    /**
     * <p>Represents the name of the "on mouse down" event. This is a string constant used by the user when setting the
     * name of the event.</p>
     */
    public static final String ON_MOUSE_DOWN_EVENT_NAME = "onMouseDown";

    /**
     * <p>Represents the name of the "on mouse wheel" event. This is a string constant used by the user when setting the
     * name of the event.</p>
     */
    public static final String ON_MOUSE_WHEEL_EVENT_NAME = "onMouseWheel";

    /**
     * <p>Represents the name of the "on mouse in" preview event. This is a string constant used by the user when
     * setting the name of the event.</p>
     */
    public static final String ON_PREVIEW_MOUSE_IN_EVENT_NAME = "onPreviewMouseIn";

    /**
     * <p>Represents the name of the "on mouse out" preview event. This is a string constant used by the user when
     * setting the name of the event.</p>
     */
    public static final String ON_PREVIEW_MOUSE_OUT_EVENT_NAME = "onPreviewMouseOut";

    /**
     * <p>Represents the name of the "on mouse up" preview event. This is a string constant used by the user when
     * setting the name of the event.</p>
     */
    public static final String ON_PREVIEW_MOUSE_UP_EVENT_NAME = "onPreviewMouseUp";

    /**
     * <p>Represents the name of the "on mouse down" preview event. This is a string constant used by the user when
     * setting the name of the event.</p>
     */
    public static final String ON_PREVIEW_MOUSE_DOWN_EVENT_NAME = "onPreviewMouseDown";

    /**
     * <p>Represents the name of the "on mouse wheel" preview event. This is a string constant used by the user when
     * setting the name of the event.</p>
     */
    public static final String ON_PREVIEW_MOUSE_WHEEL_EVENT_NAME = "onPreviewMouseWheel";

    /**
     * <p>Represents the name used to retrieve the x parameter.</p>
     */
    private static final String X = "x";

    /**
     * <p>Represents the name used to retrieve the y parameter.</p>
     */
    private static final String Y = "y";

    /**
     * <p>Represents the name used to retrieve the wheel delta parameter.</p>
     */
    private static final String WHEEL_DELTA = "wheelDelta";

    /**
     * <p>Represents the name used to retrieve the button parameter.</p>
     */
    private static final String BUTTON = "button";

    /**
     * <p>Creates new instance of {@link XREMouseEvent} class.</p>
     */
    public XREMouseEvent() {
        // empty constructor
    }

    /**
     * <p>Retrieves the position of the mouse on the x-axis at the time of the event.</p>
     *
     * @return the position of the mouse on the x-axis at the time of the event
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public int getX() {
        return getTypedParam(X, Integer.class);
    }

    /**
     * <p>Sets the position of the mouse on the x-axis at the time of the event.</p>
     *
     * @param x the position of the mouse on the x-axis at the time of the event
     *
     * @throws IllegalStateException if params is null
     */
    public void setX(int x) {
        setParam(X, x);
    }

    /**
     * <p>Retrieves the position of the mouse on the y-axis at the time of the event.</p>
     *
     * @return the position of the mouse on the y-axis at the time of the event
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public int getY() {
        return getTypedParam(Y, Integer.class);
    }

    /**
     * <p>Sets the position of the mouse on the y-axis at the time of the event.</p>
     *
     * @param y the position of the mouse on the y-axis at the time of the event
     *
     * @throws IllegalStateException if params is null
     */
    public void setY(int y) {
        setParam(Y, y);
    }

    /**
     * <p>Retrieves the amount the mouse wheel has rotated.</p>
     *
     * @return the amount the mouse wheel has rotated
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public int getWheelDelta() {
        return getTypedParam(WHEEL_DELTA, Integer.class);
    }

    /**
     * <p>Sets the amount the mouse wheel has rotated.</p>
     *
     * @param wheelDelta the amount the mouse wheel has rotated
     *
     * @throws IllegalStateException if params is null
     */
    public void setWheelDelta(int wheelDelta) {
        setParam(WHEEL_DELTA, wheelDelta);
    }

    /**
     * <p>Retrieves the mouse button that was pressed.</p>
     *
     * @return the mouse button that was pressed
     *
     * @throws IllegalStateException if the requested parameter has wrong type in the parameters map or params is null
     */
    public XREMouseButton getButton() {
        return getTypedParam(BUTTON, XREMouseButton.class);
    }

    /**
     * <p>Sets the mouse button that was pressed.</p>
     *
     * @param button the mouse button that was pressed
     *
     * @throws IllegalStateException if params is null
     */
    public void setButton(XREMouseButton button) {
        setParam(BUTTON, button);
    }
}

